package com.hyh.search.domain;



import com.hyh.search.domain.Complex.ProductComplex;
import lombok.Data;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;

@Data
public class ProductDoc {
    private Long id;
    private String title;
    private String imgSrc;
    private String color;
    private String comment;
    private Integer price;
    private String goodComment;
    private String linkUrl;
    private String shopName;
    private Integer sort;
    private Timestamp createdAt;
    private Integer stockQuantity;
    private String category;
    private List<String> suggestion;



    public ProductDoc(ProductComplex product) {
        this.id = product.getId();
        this.title = product.getTitle().replaceAll("<font[^>]*>", "").replaceAll("</font>", "");
        this.imgSrc = product.getImgSrc();
        this.color = product.getColor();
        this.comment = product.getComment();
        this.goodComment = product.getGoodComment();
        this.linkUrl = product.getLinkUrl();
        this.shopName = product.getShopName();
        this.sort = product.getSort();
        this.createdAt = product.getCreatedAt();
        this.stockQuantity = product.getStockQuantity();
        this.suggestion = new ArrayList<>();
        this.category = product.getType();
        this.price = product.getPrice();
        this.suggestion.add(this.title);
        this.suggestion.add(this.shopName);
    }
}
